package com.gohi.main.wxapi.service.impl;

import javax.servlet.http.HttpServletRequest;

import net.sf.json.JSONObject;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gohi.main.wxapi.process.MsgXmlUtil;
import com.gohi.main.wxapi.service.IwxApiProcess;
import com.gohi.main.wxapi.service.IwxControl;
import com.gohi.main.wxapi.vo.MsgRequest;


/**
 * 微信消息、接口处理类
 * @author brain
 */
@Service
public class WxApiProcessImpl implements IwxApiProcess{
	Logger log = Logger.getLogger(WxApiProcessImpl.class);
	private IwxControl wxControl;
	@Override
	public String processMsg(HttpServletRequest request, String appId,
			String appSecret) {
		// TODO Auto-generated method stub
		try {
			MsgRequest msgRequest = MsgXmlUtil.parseXml(request);//获取发送的消息
			
			/**
			 * 根据自己的业务自行处理返回的消息的模式
			 */
			return wxControl.processMsg(msgRequest,appId,appSecret);
			
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
	
	}
	public IwxControl getWxControl() {
		return wxControl;
	}
	public void setWxControl(IwxControl wxControl) {
		this.wxControl = wxControl;
	}

	
	
}

